<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width,initial-scale=1.0,maximum-scale=1.0, user-scalable=no">
<title>安装通数据中心登录</title>
<link href="/res/login/dataCenter.css" rel="stylesheet" type="text/css">
<script src="/res/vendors/select2/vendor/jquery-2.1.0.js"></script>
<script type="text/javascript" src="/res/login/jquery-starfield.js"></script>
	<!-- FastClick -->
	<script src="/res/vendors/fastclick/lib/fastclick.js"></script>
	<!-- NProgress -->
	<script src="/res/vendors/nprogress/nprogress.js"></script>
	<!--layer.js-->
	<script src="/res/layer/layer.js"></script>
	<script src="/res/login/jquery.validator.js?local=zh-CN"></script>
</head>
<body> 
<form id="loginForm">
	<div class="outerLogin">
		<img alt="" src="/res/images/login/data1_03.png">
		<div>
			<h3>
				<img alt="" src="/res/images/login/data1_06.png">
			</h3>
			<div class="pad" style="background-color: #1f2650;padding-bottom: 60px;">
				<h4>用户登录</h4>
				<div>
					<input id="user" name="user" data-value type="text" autocomplete="off" placeholder="请输入账号" required>
					<span data-value="user"></span>
				</div>
				<div>
					<input id="password" name="password" data-value type="password" placeholder="请输入密码" required>
					<span data-value="password" style="height: 24px;"></span>
				</div>
				<div>
					<input id="verCode" name="verCode" data-value type="text" placeholder="请输入验证码" required style="width: 155px" autocomplete="off">
					<span data-value="verCode" style="height: 24px;"></span>
					<label style="position: relative;top: 15px;">
						<img src="/verCode" style="height: 40px;border-radius: 3px" alt="code" onclick="randomPic()" id="imgVerCode" />
					</label>
				</div>
				<div class="remPass">
					<!--<i class="chosed"></i>-->
					<!--<dfn>记住密码</dfn>-->
					<!--<a>忘记密码？</a>-->
				</div>
				<button type="submit">登录</button>
			</div>
		</div>
	</div>
</form>
</body>
<script type="text/javascript">
$('body').starfield();
var loading;
var FormValidation = function () {
    return {
        init: function () {
            $('#loginForm').validator({
                timely:2,
                theme:'yellow_top', 
                fields: {
                    'user': 'required',
                    'password': 'required',
                    'verCode': 'required'
                } ,
				valid : function (form) {
					$.ajax({
						url :'/login' ,
						type : 'post' ,
						dataType : 'json' ,
						data : $("#loginForm").serialize(),
						beforeSend : function() {
							loading = layer.load(2);
							NProgress.start();
						},
						success: function (resJson) {
							if(resJson.success) {
								location.href = "/";
							}else{
								randomPic();
								layer.msg(resJson.msg , {time : 1000});
							}
						},
						error : function (x , t , e) {
							alert("错误："+x.status+"--"+x.responseText);
						},
						complete : function () {
							NProgress.done();
							layer.close(loading);
						}
					});
				}
            });

        } 
    }; 
}();
$(function () {
	FormValidation.init();
});

function randomPic() {
	$("#imgVerCode").attr('src', '/verCode?n=' + Math.random())
}
</script>
</html> 